// // "http-proxy-middleware": "^0."
// const createProxyMiddleware = require('http-proxy-middleware')

// // "http-proxy-middleware": "^2."
const { createProxyMiddleware } = require('http-proxy-middleware')

module.exports = function (app) {
  app.use(
    createProxyMiddleware('/phoneApi', {
      target: 'https://apis.juhe.cn/mobile/Example/query.php',
      pathRewrite: { '^/phoneApi': '' },
      changeOrigin: true,
      secure: true, //如果访问的是https类的链接，就需要设置为true
      ws: false,
    }),
  )
  app.use(
    createProxyMiddleware('/sfz', {
      target: 'http://m.shenfenzheng.293.net/ids.php',
      changeOrigin: true,
      secure: false, //如果访问的是https类的链接，就需要设置为true
      ws: false,
      pathRewrite: { '^/sfz': '' },
    }),
  )
}
